#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPropertyAnimation>
#include<QParallelAnimationGroup>
#include<QSequentialAnimationGroup>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //geometry 几何动画
    QPropertyAnimation *a1 = new QPropertyAnimation(ui->pushButton,"geometry");
    a1->setDuration(3000);
    a1->setStartValue(ui->pushButton->geometry());
    a1->setEndValue(QRect(50,200,100,50));

    QPropertyAnimation *a2 = new QPropertyAnimation(ui->pushButton_2,"geometry");
    a2->setDuration(3000);
    a2->setStartValue(ui->pushButton_2->geometry());
    a2->setEndValue(QRect(50,200,100,50));

    QPropertyAnimation *a3 = new QPropertyAnimation(ui->pushButton_3,"geometry");
    a3->setDuration(3000);
    a3->setStartValue(ui->pushButton_3->geometry());
    a3->setEndValue(QRect(50,200,100,50));

    QEasingCurve curve;
    curve.setType(QEasingCurve::OutBounce);
    curve.setAmplitude(1.0);
    curve.setOvershoot(1.7);
    curve.setPeriod(0.3);

    a1->setEasingCurve(curve);
    a2->setEasingCurve(curve);
    a3->setEasingCurve(curve);
/*
    QParallelAnimationGroup * g = new QParallelAnimationGroup;
    g->addAnimation(a1);
    g->addAnimation(a2);
    g->addAnimation(a3);
    g->start();
*/
    // sequential animation group
    QSequentialAnimationGroup *sg = new QSequentialAnimationGroup();
    sg->addAnimation(a1);
    sg->addAnimation(a2);
    sg->addAnimation(a3);

    sg->start();

}

MainWindow::~MainWindow()
{
    delete ui;
}
